import pandas as pd
import matplotlib.pyplot as plt


# 读取CSV文件 改为对应的 csv 文件
file_path = './2023-11.csv'
df = pd.read_csv(file_path)
# 全局设置字体
plt.rcParams['font.sans-serif'] = ['STHeiti']  # 'SimHei' 是黑体的意思
# plt.rcParams['font.family']='STHeiti'
plt.rcParams['axes.unicode_minus'] = False 


# 计算每个厂商的总销量并找出前10名
total_sales_by_manufacturer = df.groupby('厂商')['销量'].sum().nlargest(10)


# 绘制条形图
plt.figure(figsize=(10, 6))
total_sales_by_manufacturer.plot(kind='bar')
plt.title('Top 10 Manufacturers by Total Sales')
plt.xlabel('Manufacturer')
plt.ylabel('Total Sales')
plt.xticks(rotation=45)
plt.grid(True)
plt.show()
